﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetFrame;
using NetFrame.Log;
using LOLServer.Logic;
using LOLServer.Logic.Login;
using NetFrame.Auto;
using GameProtocol;
using Protocol = GameProtocol.Protocol;


namespace LOLServer
{
    public class HandlerCenter : AbsHandlerCenter
    {
        HandlerInterface mLogin;
        private HandlerInterface mUser;

        public HandlerCenter()
        {
            mLogin = new LoginHandler();
            mUser = new LoginHandler();
        }

        public override void ClientClose(UserToken token, string error)
        {
            mLogin.ClientClose(token, error);
        }

        public override void ClientConnect(UserToken token)
        {
            Logger.Info("客户端连接:");
        }

        public override void MessageReceive(UserToken token, object message)
        {
            SocketModel model = message as SocketModel;
            switch (model.Type)
            {
                case Protocol.TYPE_LOGIN:
                    mLogin.MessageReceive(token, model);
                    break;
                case Protocol.TYPE_USER:
                    mUser.MessageReceive(token, model);
                    break;
                default:
                    Logger.Error("客户端没有传输过来协议的模块类型");
                    break;
            }
        }
    }
}
